<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑阵容类型</title>
    <style>
        .two-part-label{
            width: 200px !important;
        }
    </style>
</head>
<body>
<script type="text/html" id="form">
    <input type="hidden" name="id" value="{{ d.id }}" />
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text style="color:red;">*</text>
                    活动名称</label>
                <div class="layui-input-block">
                    <input type="text" name="activity_name" placeholder="请输入活动名称" class="layui-input" lay-verify="required"
                           autocomplete="off" value="{{ d.activity_name }}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">未开启标签</label>
                <div class="layui-input-block">
                    <div class="xmSelect"
                         data-name="tag"
                         data-sourceType="route"
                         data-source="/admin.sky.tag/index"
                         data-params='{"search_param":{"type":{"value":1,"condition":"="}}}'
                         data-textField="tag"
                         data-valueField="id"
                         data-paging="true"
                         data-radio="true"
                         data-layVerify="required"
                         data-direction="down"
                         data-selected="{{=d.tag}}"
                    >
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">进行中标签</label>
                <div class="layui-input-block">
                    <div class="xmSelect"
                         data-name="now_tag"
                         data-sourceType="route"
                         data-source="/admin.sky.tag/index"
                         data-params='{"search_param":{"type":{"value":2,"condition":"="}}}'
                         data-textField="tag"
                         data-valueField="id"
                         data-paging="true"
                         data-radio="true"
                         data-layVerify="required"
                         data-direction="down"
                         data-selected="{{=d.now_tag}}"
                    >
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text style="color:red;">*</text>活动时间</label>
                <div class="layui-input-block">
                    <input type="text"
                           name="time"
                           class="layui-input laydate"
                           data-type="datetime"
                           data-isRange="true"
                           id="start_time"
                           readonly="readonly"
                           value="{{ d.time}}"
                           placeholder="活动时间">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"><text style="color:red;">*</text>图示</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="icon"
                         data-accept="image"
                         data-type="ali-oss"
                         data-uploaded="{{ d.icon }}"
                         data-uploadedId="{{ d.icon }}"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>


            <div class="layui-form-item"><text style="color:red;">图片尺寸建议 3 * 2比例效果最佳</text>
                <label class="layui-form-label"><text style="color:red;">*</text>正文</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="image"
                         data-accept="image"
                         data-type="ali-oss"
                         data-multi="true"
                         data-uploaded="{{ d.activity_img }}"
                         data-uploadedId="{{ d.activity_img }}"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">跳转先祖</label>
                <div class="layui-input-block">
                    <div class="xmSelect"
                         data-name="target"
                         data-sourceType="route"
                         data-source="/admin.sky.ancestor/index"
                         data-textField="name"
                         data-valueField="id"
                         data-paging="true"
                         data-radio="true"
                         data-selected="{{d.target}}"
                         data-direction="down">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">跳转季节</label>
                <div class="layui-input-block">
                    <div class="xmSelect"
                         data-name="target_season"
                         data-sourceType="route"
                         data-source="/admin.sky.goods/filterGuide"
                         data-textField="name"
                         data-valueField="name"
                         data-paging="true"
                         data-radio="true"
                         data-selected="{{d.target_season}}"
                         data-direction="down"
                    ></div>
                </div>
            </div>



            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label"><text style="color:red;">*</text>活动描述</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入活动描述" name="activity_desc" class="layui-textarea" lay-verify="required">{{ d.activity_desc}}</textarea>
                </div>
            </div>

        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="laytp-form">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>

    layui.use(['laytp','admin'],function(){
        let form = layui.form;
        let $ = layui.jquery;
        //获取参数ID
        var id = facade.getUrlParam('id');
        if(!id){
            facade.error('参数ID不能为空');
            return false;
        }
        //获取数据，渲染到对应的节点上
        facade.ajax({
            route: "/admin.sky.activity/info",
            data: {id: id},
            successAlert: false,
            showLoading: true
        }).done(function(res){
            if(res.code === 0){
                layui.laytpl($("#form").html()).render(res.data,function(string){
                    $("form").html(string);
                    layui.laytpForm.render();
                    form.render();
                });
            }
        });

        form.on('submit(laytp-form)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.sky.activity/edit',
                data:data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.funController.tableRender();
                    parent.parent.renderMenu();//重新渲染菜单
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>